<template>
	<view class="waikuang">
		<view class="mdxx" @click="goshangjxx">
				<image class="mdtup" :src="imgUrl + storeData.image[0]" mode="aspectFill"></image>
			<view class="mdxinx">
				<view>{{storeData.mdname}}</view>
				<view class="dizhi">
					<image class="dizhtp" src="../../static/dizhi.png" mode=""></image>
					<view class="dizhi">{{storeData.city+storeData.address}}</view>
				</view>
			</view>
			<image class="chakan" src="../../static/go.png"></image>
		</view>
		<view class="paiduiqk">
			<scroll-view class="xingxtq" scroll-x="true">
				<view class="gundong" :style="{'width':kuan}">
					<view class="jvzhong" @click="xzfxshi(index,item.id)" v-for="(item,index) in staffData" :key="index">
						<view :class="dqxz==index?'shejisk yixz':'shejisk wxz'">
							<image class="fximg" v-if="item.touxiang!=null&&item.touxiang!='undefind'&&item.touxiang!=''" :src="imgUrl+item.touxiang" mode="aspectFill"></image>
							<image class="fximg" v-else src="../../static/touxw.png" mode="aspectFill"></image>
							<!-- <view>{{item.name}}</view> -->
							<view>{{item.phone}}</view>
						</view>
						<view :class="dqxz==index?'jtcx':'jtyc'"></view>
					</view>
				</view>
			</scroll-view>
			<view class="paidqk">
				<view :class="item.fwzt==1?'paihao dqyh':item.kehu.id == userInfo.id?'paihao my':'paihao paid'" v-for="(item,index) in customerData" :key="index">
					<view class="jbxx">
						<view class="xingm">{{item.kehu.name==null||item.kehu.name=='undefind'||item.kehu.name==''?'李某某':item.kehu.name}}</view>
						<view>剪头发</view>
					</view>
					<view>APP排队</view>
				</view>
				<view class="mypai" @click="send()">选此发型师排队</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{},
				dqxz: 0,
				kuan: '1100rpx',
				imgUrl: getApp().globalData.imgUrl,
				mendian_id: '', //门店id
				lfsid:'',//理发师id
				kehu_id: '',
				storeData:[],//获取的门店数据
				staffData:[],//门店下的员工
				customerData:[]//客户数据
			}
		},
		onLoad(o) {
			this.userInfo = uni.getStorageSync('user_key');
			// console.log(111,this.userInfo)
			this.mendian_id = o.id
		},
		onShow() {
			//获取门店信息
			this.getMendxq(this.mendian_id);
		},
		methods: {
			//选择理发师
			xzfxshi(index,id) {
				this.dqxz = index;
				this.lfsid=id;
				
				this.getDqpaid(id);
			},
			// 商家信息
			goshangjxx() {
				uni.navigateTo({
					url: '../shangjxx/shangjxx?id=' + this.mendData.id
				})
			},
			//获取门店信息
			getMendxq(id) {
				uni.request({
					url: getApp().globalData.url + '/client/GetMendxq',
					data: {
						id: id,
					},
					method: "GET",
					header: {
						"Content-Type": "application/json"
					},
					success: (res) => {
						this.storeData = res.data.data;
						// console.log(444,res)
						this.staffData=res.data.data.yuangong;
						this.getDqpaid(this.staffData[0].id)
					}
				})
			},
			//获取理发师的排队客户
			getDqpaid(lfsid) {
				uni.request({
					url: getApp().globalData.url + '/client/GetLfsPdui',
					data: {
						lfsid: lfsid,
					},
					method: "GET",
					header: {
						"Content-Type": "application/json"
					},
					success: (res) => {
							// console.log(111,res)
						if (res.data.code == 200&&res.data.msg=='查询成功') {
							this.customerData=[];
							this.customerData = res.data.data;
							 this.$forceUpdate();//强制更新
						}

					}
				})
			},
			//提交选中发型师排队
			send() {
				if(this.lfsid==''){
					uni.showToast({
						title: '请选择理发师哦',
					});
					return;
				}
				uni.request({
					url: getApp().globalData.url + '/client/AddUspaid',
					data: {
						khid: this.userInfo.id,
						lfsid: this.lfsid,
						mdid: this.mendian_id,
					},
					method: "POST",
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					success: (res) => {
						// console.log(4444, res)
						if (res.data.code == 200) {
							uni.showToast({
								title: '排队成功',
							});	
							//重新获取理发师的排队情况
							this.getDqpaid(this.lfsid)
							uni.setStorageSync('lfsid',this.lfsid)
						} else {
							uni.showToast({
								title: '排队失败',
								icon: "none"
							});
						}
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background: #f0f0f0;
	}
</style>
<style lang="scss" scoped>
	.waikuang {
		width: 710rpx;
		padding: 20rpx;

		.mdxx {
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: #ffffff;
			padding: 20rpx;
			border-radius: 20rpx;

			.mdtup {
				width: 100rpx;
				height: 100rpx;
				border-radius: 10rpx;
			}

			.mdxinx {
				width: 510rpx;
				margin-left: 20rpx;

				.dizhi {
					display: flex;
					align-items: center;
					font-size: 25rpx;
					color: #828282;
					margin-top: 10rpx;

					.dizhtp {
						width: 30rpx;
						height: 30rpx;
					}

					.dizhi {
						width: 450rpx;
						display: block;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}
			}

			.chakan {
				width: 50rpx;
				height: 50rpx;
			}
		}

		.paiduiqk {
			border-radius: 20rpx;
			padding: 20rpx;
			background: #ffffff;
			margin-top: 20rpx;

			.paidqk {
				width: 670rpx;
				border-top: solid 1rpx #d1d1d1;

				.dqyh {
					background: #ffb8ea;
					color: #ff007f;
				}

				.paid {
					background: #e5e5e5;
					color: #595b5f;
				}

				.my {
					background: #d2eae2;
					color: #719c93;
				}

				.mypai {
					margin-top: 20rpx;
					border-radius: 40rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 20rpx 40rpx;
					font-size: 28rpx;
					background: #ff007f;
					color: #ffffff;
				}

				.paihao {
					margin-top: 20rpx;
					border-radius: 40rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 20rpx 40rpx;
					font-size: 28rpx;

					.jbxx {
						display: flex;
						align-items: center;

						.xingm {
							font-weight: bold;
							margin-right: 10rpx;
						}
					}
				}
			}

			.xingxtq {
				width: 670rpx;

				.gundong {
					display: flex;
					padding-right: 20rpx;

					// width: 200rpx;
					.jvzhong {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
						margin-bottom: 20rpx;

						.jtcx {
							width: 0rpx;
							height: 0rpx;
							border-top: 25rpx solid #ff007f;
							border-right: 25rpx solid transparent;
							border-left: 25rpx solid transparent;
							margin-left: 20rpx;
						}

						.jtyc {
							width: 0rpx;
							height: 0rpx;
							border-top: 25rpx solid #ffffff;
							border-right: 25rpx solid transparent;
							border-left: 25rpx solid transparent;
							margin-left: 20rpx;
						}

						.shejisk {
							width: 160rpx;
							padding: 20rpx;
							border-radius: 20rpx;
							margin-left: 20rpx;
							text-align: center;
							font-size: 30rpx;

							.fximg {
								width: 120rpx;
								height: 120rpx;
								border-radius: 60rpx;
							}

							.fxname {
								font-size: 28rpx;
								color: #808080;
								margin-top: 5rpx;
							}
						}

						.yixz {
							background-color: #ff007f;
							color: #ffffff;
						}

						.wxz {
							background-color: #efefef;
						}
					}

				}


			}
		}
	}
</style>
